/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PrintOrderForm.java
 *
 * Created on 28-11-2011, 20:10:01
 */
package GUILag;
import java.awt.print.*;
import java.awt.*;
import ModelLag.*;
import ControllerLag.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
/**
 * ViewOrderForm is used to view or change an order in the ordertable, in orderframe
 * ViewOrder implements printable, since the orderframe should be printable
 * @author Ronni
 *      
 */
public class ViewOrderForm extends javax.swing.JFrame  implements Printable {

    private OrderArr currentOrder;
    private OrderArrCTR orderCTR;
    private EmployeeCTR employeeCTR;
    private CustomerCTR customerCTR;
    private EventCTR eventCTR;
    private RoomCTR roomCTR;
    private OrderFrame orderFrame;
    private int row;
    /*
     * Constructor, instantiates controllerclasses, sets the fields and comboboxes
     * in the vieworderframe.
     * @param orderID takes the orderID for the order to show
     * @param orderFrame takes the frame the window is comming from, to get the update methods for the table
     * @param row gets the row of the order, in order to update the correct row
     */
    public ViewOrderForm(int orderID, OrderFrame orderFrame,int row) {
        initComponents();
        orderCTR = new OrderArrCTR();
        employeeCTR = new EmployeeCTR();
        customerCTR = new CustomerCTR();
        eventCTR = new EventCTR();
        roomCTR = new RoomCTR();
        this.orderFrame = orderFrame;
        this.row = row;
        
        currentOrder = orderCTR.findOrderArr(orderID);
        populateComboBoxes();
        
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        Date newdate = new Date(currentOrder.getDate().getTimeInMillis());        
        txtName.setText(currentOrder.getCustomer().toString());
        txtPhone.setText(currentOrder.getCustomer().getPhoneNo());
        txtDate.setText(sdf.format(newdate));
        txtStartTime.setText(currentOrder.getStartTime().substring(0, 5));
        txtEndTime.setText(currentOrder.getEndTime().substring(0,5));
        txtBowlingFrom.setText(currentOrder.getBowlingFrom().substring(0, 5));
        txtAmountPersons.setText(""+currentOrder.getNoOfPersons()+"");
        txtAmountPersonsOnlyFood.setText(""+currentOrder.getNoOfPersonsOnlyFood()+"");
        txtAmountLanes.setText(""+currentOrder.getAmountOfLanes()+"");
        comboRoom.setSelectedItem(currentOrder.getRoom());
        comboEmpl.setSelectedItem(currentOrder.getEmployee());
        txtDescription.setText(currentOrder.getDescription());
        comboEvent.setSelectedItem(currentOrder.getEvent());      
        
        
    }    
    /*
     * Populates the comboboxes in the form
     */
    private void populateComboBoxes()
    {
            for(Employee employees : employeeCTR.getAllEmployees() )
            {
                if(employees.getCprNo().equals(currentOrder.getEmployee().getCprNo()))
                {
                comboEmpl.addItem(currentOrder.getEmployee());
                }else{
                    comboEmpl.addItem(employees);
                }
            } 
            for(ModelLag.Event events : eventCTR.getAllEvent())
            {
                if(events.getEventName().equals(currentOrder.getEvent().getEventName()))
                {
                    comboEvent.addItem(currentOrder.getEvent());
                }else{
                comboEvent.addItem(events);
                }
            }   
            
            for(Room rooms : roomCTR.getAllRooms())
            {
                if(rooms.getRoomName().equals(currentOrder.getRoom().getRoomName()))
                {
                    comboRoom.addItem(currentOrder.getRoom());
                }else{
                    comboRoom.addItem(rooms);
                }
                }
                
            

            
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDescription = new javax.swing.JTextArea();
        comboEmpl = new javax.swing.JComboBox();
        comboEvent = new javax.swing.JComboBox();
        jButton3 = new javax.swing.JButton();
        comboRoom = new javax.swing.JComboBox();
        txtName = new javax.swing.JFormattedTextField();
        txtPhone = new javax.swing.JFormattedTextField();
        txtDate = new javax.swing.JFormattedTextField();
        txtStartTime = new javax.swing.JFormattedTextField();
        txtEndTime = new javax.swing.JFormattedTextField();
        txtBowlingFrom = new javax.swing.JFormattedTextField();
        txtAmountPersons = new javax.swing.JFormattedTextField();
        txtAmountPersonsOnlyFood = new javax.swing.JFormattedTextField();
        txtAmountLanes = new javax.swing.JFormattedTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Vis Ordre");
        setAlwaysOnTop(true);
        setResizable(false);
        setType(java.awt.Window.Type.POPUP);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jButton1.setText("Udskriv...");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Tilbage");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel1.setText("Tlf");

        jLabel2.setText("Start Tidspunkt");

        jLabel3.setText("Slut Tidspunkt");

        jLabel4.setText("Navn");

        jLabel5.setText("Dato");

        jLabel6.setText("Antal Personer, Kun mad");

        jLabel7.setText("Antal Personer");

        jLabel8.setText("ArrangementsType");

        jLabel10.setText("Antal Baner");

        jLabel11.setText("Modtaget af");

        jLabel12.setText("Lokale");

        jLabel13.setText("Bowling fra");

        txtDescription.setColumns(20);
        txtDescription.setRows(5);
        jScrollPane1.setViewportView(txtDescription);

        jButton3.setText("Opdater");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        txtName.setEditable(false);

        txtPhone.setEditable(false);

        txtDate.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM))));

        try {
            txtStartTime.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            txtEndTime.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            txtBowlingFrom.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        txtAmountPersons.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####"))));

        txtAmountPersonsOnlyFood.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####"))));

        txtAmountLanes.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("##"))));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                        .addComponent(jButton1)
                        .addGap(31, 31, 31)
                        .addComponent(jButton2))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboEmpl, 0, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboRoom, 0, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBowlingFrom, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtAmountPersons, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtAmountPersonsOnlyFood, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtAmountLanes, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtEndTime, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtStartTime, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDate, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboEvent, 0, 213, Short.MAX_VALUE)
                            .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton2, jLabel1, jLabel10, jLabel11, jLabel12, jLabel13, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(comboEvent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtEndTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(txtBowlingFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtAmountPersons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtAmountPersonsOnlyFood, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txtAmountLanes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(comboRoom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(comboEmpl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
/*
     * prints the current form, creates printerjob and prints
     */
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
         PrinterJob job = PrinterJob.getPrinterJob();
         Book book = new Book();
         book.append(this, job.defaultPage());
         job.setPageable(book);
         boolean ok = job.printDialog();
         if (ok) {
             try {
                  job.print();
             } catch (PrinterException ex) {
              /* The job did not successfully complete */
             }
         }
}//GEN-LAST:event_jButton1ActionPerformed
/*
 * closes form
 */
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    orderFrame.setEnabled(true);
    orderFrame.toFront();    
    this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
/*
 * updates the orderobject, and commits it to the database
 * handles type conversion, since dates have to match the DB types  
 */
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    SimpleDateFormat newDateFormat = new SimpleDateFormat("dd-MM-yyyy");
    try{
    GregorianCalendar newDate = new GregorianCalendar();
    newDate.setTime(newDateFormat.parse(txtDate.getText()));
    int orderID = currentOrder.getOrderID();
    String startTime = txtStartTime.getText().toString();
    String endTime = txtEndTime.getText().toString();
    int amountLanes = Integer.parseInt(txtAmountLanes.getText().toString());
    int noPersons = Integer.parseInt(txtAmountPersons.getText().toString());
    int noPersonsFood = Integer.parseInt(txtAmountPersonsOnlyFood.getText().toString());
    Customer theCustomer = customerCTR.findCustomer(txtPhone.getText().toString()); 
    Employee theEmployee = (Employee)comboEmpl.getSelectedItem();
    Room theRoom = (Room)comboRoom.getSelectedItem();
    ModelLag.Event theEvent = (ModelLag.Event)comboEvent.getSelectedItem();    
    String description = txtDescription.getText().toString().trim();
    String bowlingFrom = txtBowlingFrom.getText().toString().trim();
    orderCTR.updateOrderArr(orderID,newDate,startTime,endTime,amountLanes,noPersons,noPersonsFood,theCustomer,theEmployee, theRoom,theEvent, description, bowlingFrom); //SÆT VARIABLER IND
    double totalPrice = (noPersons*theEvent.getPricePrPerson()) + (noPersonsFood*theEvent.getPricePrPersonOnlyFood());
    orderFrame.updateRow(currentOrder.getOrderID(),newDate, startTime, endTime, amountLanes, noPersons,noPersonsFood, theCustomer.toString(),theEmployee.getfName() + " " + theEmployee.getlName(),theRoom.getRoomName(),theEvent.getEventName(),description,bowlingFrom,  row);
    orderFrame.setEnabled(true);
    orderFrame.toFront();
    this.dispose();
    }catch(Exception e){
        String message = "Der er sket en fejl under opdatering, indtastede data er muligvis invalide";
        Object[] options = {"Ok"};
        JOptionPane.showOptionDialog(this, message, "Der er sket en fejl.", JOptionPane.ERROR_MESSAGE, JOptionPane.ERROR_MESSAGE, null, options, "");    
    }
     
    
}//GEN-LAST:event_jButton3ActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    orderFrame.setEnabled(true);
    orderFrame.toFront();    
}//GEN-LAST:event_formWindowClosing

    @Override
    public int print(Graphics g, PageFormat pf, int page) throws
                                                        PrinterException {
                if (page != 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }
 
        /* User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());
 
        /* Now print the window and its visible contents */
        this.printAll(g);
 
        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;
    }
 
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ViewOrderForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ViewOrderForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ViewOrderForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ViewOrderForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox comboEmpl;
    private javax.swing.JComboBox comboEvent;
    private javax.swing.JComboBox comboRoom;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JFormattedTextField txtAmountLanes;
    private javax.swing.JFormattedTextField txtAmountPersons;
    private javax.swing.JFormattedTextField txtAmountPersonsOnlyFood;
    private javax.swing.JFormattedTextField txtBowlingFrom;
    private javax.swing.JFormattedTextField txtDate;
    private javax.swing.JTextArea txtDescription;
    private javax.swing.JFormattedTextField txtEndTime;
    private javax.swing.JFormattedTextField txtName;
    private javax.swing.JFormattedTextField txtPhone;
    private javax.swing.JFormattedTextField txtStartTime;
    // End of variables declaration//GEN-END:variables
}
